package cn.rocksolid.sport.common.error;

/**
 * RockSolid exception
 * 
 * @author Axl Zhao
 * @email axl.zhao@163.com
 */
public final class RockSolidException extends RuntimeException {
  /**
   * Random serialVersionUID
   */
  private static final long serialVersionUID = 8273416039413940631L;

  private final RSE rse;

  public RockSolidException() {
    this(null);
  }

  public RockSolidException(final RSE rse) {
    super(null == rse ? RSE.UNKNOWN.message() : rse.message());
    this.rse = null == rse ? RSE.UNKNOWN : rse;
  }

  public RockSolidException(final RSE rse, final Throwable throwable) {
    super(throwable);
    this.rse = null == rse ? RSE.UNKNOWN : rse;
  }

  public RSE getRse() {
    return rse;
  }

  @Override
  public synchronized Throwable fillInStackTrace() {
    return this;
  }

  public static final RockSolidException unsupportedOperation() {
    return new RockSolidException(RSE.UNSUPPORTED_OPERATION);
  }

  public static final RockSolidException unsupportedType() {
    return new RockSolidException(RSE.UNSUPPORTED_TYPE);
  }
}
